package com.example.selectdorm.service;

import com.example.selectdorm.entity.UserAuthCode;
import com.example.selectdorm.repo.UserAuthCodeRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@AllArgsConstructor
public class UserAuthCodeService {
    private final UserAuthCodeRepository userAuthCodeRepository;

    public Boolean verifyUserAuthCode(Long uid, String authCode) {
        Optional<UserAuthCode> userAuthCode = userAuthCodeRepository.findByUid(uid);
        if(userAuthCode.isPresent()){
            return authCode.equals(userAuthCodeRepository.findByUid(uid).get().getAuthCode());
        }
        else {
            return false;
        }
    }

}
